﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using MuseLibrary.EncodingHelpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MuseLibraryTests
{
    [TestClass]
    public class RemainderParserFixture
    {
        [TestMethod]
        public void CanParseRemainder()
        {
            var remainderParser = new RemainderParser(23);
            var bitStream = "1000".ToBools();
            var counter = 0;
            while (!remainderParser.ReadBit(bitStream[counter]))
            {
                counter++;
            }

            Assert.AreEqual(8, remainderParser.Remainder);

            remainderParser.ResetState(23);
            bitStream = "11110".ToBools();
            counter = 0;
            while (!remainderParser.ReadBit(bitStream[counter]))
            {
                counter++;
            }

            Assert.AreEqual(21, remainderParser.Remainder);

            remainderParser.ResetState(23);
            bitStream = "10010".ToBools();
            counter = 0;
            while (!remainderParser.ReadBit(bitStream[counter]))
            {
                counter++;
            }

            Assert.AreEqual(9, remainderParser.Remainder);
        }
    }
}
